package com.gary.spring.bean;

import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.annotation.Resource;

/**
 * @author peng_rui
 * @date 2022/6/21
 */
@Data
@Slf4j
@Component
public class Bean1 {

    private String home;

    @Autowired
    public void autoBean2(Bean2 bean2) {
        log.info("Autowired 依赖注入 bean2");
    }

    @Resource
    public void autoBean3(Bean3 bean3) {
        log.info("Resource 依赖注入 bean3");
    }

    @Autowired
    public void autoValue(@Value("${JAVA_HOME}") String home) {
        log.info("Value 依赖注入 home : " + home);
        this.home = home;
    }

    @PostConstruct
    public void post() {
        log.info("初始化方法。。。");
    }

    @PreDestroy
    public void destroy() {
        log.info("销毁。。。");
    }
}
